public class InverseConnector<INPUT, OUTPUT, MESSAGE> implements Processor<INPUT, OUTPUT> {
	private Reader<OUTPUT, MESSAGE> reader;
	private Writer<INPUT> writer;
	public InverseConnector(Writer<INPUT> writer, Reader<OUTPUT, MESSAGE> reader) {
		setWriter(writer);
		setReader(reader);
	}
	public OUTPUT process(INPUT input) throws ProcessorException {
		try {
			writer.write(input);
			return reader.read();
		} catch (ReaderException exception) {
			throw new ProcessorException(exception);
		} catch (WriterException exception) {
			throw new ProcessorException(exception);
		} catch (CommunicationException exception) {
			throw new ProcessorException(exception);
		} catch (RuntimeException exception) {
			throw new ProcessorException(exception);
		} catch (Exception exception) {
			throw new ProcessorException(exception);
		}
	}
	public Reader<OUTPUT, MESSAGE> getReader() {
		return reader;
	}
	public void setReader(Reader<OUTPUT, MESSAGE> reader) {
		this.reader = reader;
	}
	public Writer<INPUT> getWriter() {
		return writer;
	}
	public void setWriter(Writer<INPUT> writer) {
		this.writer = writer;
	}
}

